package com.csyf.manager.channel.base;

import com.csyf.manager.entity.SysAgentChannel;
import com.csyf.manager.entity.SysPaymentChannel;
import com.csyf.manager.service.impl.RedisService;
import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 通道配置信息
 */
@Service
@Slf4j
public class BaseChannelBizImpl {

    @Autowired
    private RedisService redisService;

    /**
     * 获取交易支付通道
     * @param vo
     * @param srcMerchId
     * @return
     */
    public SysAgentChannel getTradeChannel(TrandeVo vo, String srcMerchId) {
        String channelStr = redisService.getSrcChannelInfo(vo.getMch_id(), srcMerchId);
        SysAgentChannel sysAgentChannel = new Gson().fromJson(channelStr, SysAgentChannel.class);
        return sysAgentChannel;
    }

    /**
     * 获取代付支付通道
     * @param mchId
     * @param srcMerchId
     * @return
     */
    public SysPaymentChannel getPaymentChannel(String mchId, String srcMerchId) {
        String channelString = redisService.getPaymentChannelInfo(mchId, srcMerchId);
        SysPaymentChannel sysPaymentChannel = new Gson().fromJson(channelString, SysPaymentChannel.class);
        return sysPaymentChannel;
    }



}
